﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WordBrowse.aspx.cs" Inherits="SkWeb.FAXZ.WordBrowse" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../easyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />

  
    <script src="../easyui/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="../easyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        /*
        获取指定的URL参数值
        URL:http://www.blogjava.net/blog?name=bainian
        参数：paramName URL参数
        调用方法:getParam("name")
        返回值:bainian
        */
        //1.
        function getParam(paramName) {
            paramValue = "";
            isFound = false;
            if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
                arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&");
                i = 0;
                while (i < arrSource.length && !isFound) {
                    if (arrSource[i].indexOf("=") > 0) {
                        if (arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase()) {
                            paramValue = arrSource[i].split("=")[1];
                            isFound = true;
                        }
                    }
                    i++;
                }
            }
            return paramValue;
        }


        function openDocFile(name) {

            var TANGER_OCX_OBJ = document.getElementById("TANGER_OCX");
            TANGER_OCX_OBJ.OpenFromURL("../DOC/" + name);
            //TANGER_OCX_OBJ.
        }
        function test() {
            var TANGER_OCX_OBJ = document.getElementById("TANGER_OCX");
            TANGER_OCX_OBJ.ActiveDocument.ActiveWindow.DocumentMap = true;
            // TANGER_OCX_OBJ.SaveToURL("../Files/新井--压力1.doc"); //("upload.asp", "EDITFILE", "", "newdoc.doc", 0);
        }

        function SaveFile() {//保存
            var TANGER_OCX_OBJ = document.getElementById("TANGER_OCX");
            if (TANGER_OCX_OBJ === null || TANGER_OCX_OBJ === "undefined") { return false; }
            var fileName = "temp.doc"; // document.getElementById("fileName").value;
            try {
                var tmp_id = escape(getParam("tempalteid"));
                var jing_id = escape(getParam("id"));
                var tjyy = escape(getParam("tjyy"));
                if (tjyy == "1") {
                    var message = TANGER_OCX_OBJ.SaveToURL("WordBrowse.aspx?audit=1&op=saveWordDoc&tempalteid=" + tmp_id + "&id=" + jing_id, "editfile", "", fileName, "form1");
                }
                else {
                    var message = TANGER_OCX_OBJ.SaveToURL("WordBrowse.aspx?audit=0&op=saveWordDoc&tempalteid=" + tmp_id + "&id=" + jing_id, "editfile", "", fileName, "form1");
                }
            }
            catch (err) {
                alert("err:" + err.number + ":" + err.description);
            } finally { }
        }

        function AuditSaveFile() {//保存
            var TANGER_OCX_OBJ = document.getElementById("TANGER_OCX");
            if (TANGER_OCX_OBJ === null || TANGER_OCX_OBJ === "undefined") { return false; }
            var fileName = "temp.doc"; // document.getElementById("fileName").value;
            try {
                var tmp_id = escape(getParam("tempalteid"));
                var jing_id = escape(getParam("id"));
                var message = TANGER_OCX_OBJ.SaveToURL("WordBrowse.aspx?audit=1&op=saveWordDoc&tempalteid=" + tmp_id + "&id=" + jing_id, "editfile", "", fileName, "form1");
            }
            catch (err) {
                alert("err:" + err.number + ":" + err.description);
            } finally { }
        }


        $(function () {
            if (request("hide_div_tool") == "1") {
                $(".tool_div").css("display", "none");
                //alert($(".tool_div"));
            }

            $("#save").click(function () {
                if (true) {

                    var TANGER_OCX_OBJ = document.getElementById("TANGER_OCX");
                    if (TANGER_OCX_OBJ === null || TANGER_OCX_OBJ === "undefined") { return false; }
                    // TANGER_OCX_OBJ.ActiveDocument.Protect(3); //wdAllowOnlyReading=3
                }
                SaveFile();
                parent.closeTab();
            });
        });

    </script>
    <script type="text/jscript" for="TANGER_OCX" event="OnFileCommand(cmd,canceled)">
		if (cmd == 3) //user has clicked on file save menu or button
		{
			//save to server
			//cancel default process
			//TANGER_OCX_SaveEditToServerDisk();
            //alert("dd");
             var TANGER_OCX_OBJ = document.getElementById("TANGER_OCX");
            if (TANGER_OCX_OBJ === null || TANGER_OCX_OBJ === "undefined") { return false; }
            var fileName = "temp.doc"; // document.getElementById("fileName").value;
            try {
                var tmp_id = escape(getParam("tempalteid"));
                var jing_id = escape(getParam("id"));
                var message = TANGER_OCX_OBJ.SaveToURL("WordBrowse.aspx?op=saveWordDoc&tempalteid=" + tmp_id + "&id=" + jing_id, "editfile", "", fileName, "form1");
            }
            catch (err) {
                alert("err:" + err.number + ":" + err.description);
            } finally { }



			document.all("TANGER_OCX").CancelLastCommand = true;
		}
    </script>
    <script type="text/jscript">
        var p_safe = 0;
        function tt() {
            var tmp_id = escape(getParam("tempalteid"));
            var fj = "";
            {
                var strData = request("data");
                var cs = request("cs");
                //alert(cs);
                CopyTextToBookMark(cs, "层数");
              //  CopyTextToBookMark('222', "油顶");
                var pairs = strData.split(";"); // Break at
                var wjymd = ""; //完井液密度
                var skjd2 = ""; //射孔井段
                var jyzyl = "0"; //静液柱压力
                var wd = "0"; //温度
                var qcyzsd = ''; //前磁遇阻深度
                for (var i = 0; i < pairs.length - 1; i++) {
                    pairs_ = pairs[i].split(',');

                    if (pairs_[1] == "垂直深度") {
                        skjd2 = pairs_[0];

                        if (skjd2 != "") {
                            wd = skjd2 * 0.035;
                            wd = wd.toFixed(0);

                        }
                        CopyTextToBookMark(wd, "温度");
                        CopyTextToBookMark(pairs_[0], "垂直深度");


                        if (wjymd != "" && skjd2 != "") {
                            jyzyl = wjymd * skjd2 * 0.0098;
                        }
                        jyzyl = jyzyl.toFixed(2);
                        CopyTextToBookMark(jyzyl, "静液柱压力");
                       // CopyTextToBookMark(jyzyl, "ρ");
                    }
                    else if (pairs_[1] == "完井液密度") {
                        CopyTextToBookMark(pairs_[0], "完井液密度");
                        wjymd = pairs_[0];
                    }
                    else {

                        CopyTextToBookMark(pairs_[0], pairs_[1]);


                        if (pairs_[1] == "前磁遇阻深度") {

                           // alert("1");
                            qcyzsd = pairs_[0];
                        }
                        if (pairs_[1] == "阻流环深度") {
                           // alert("2");
                            //alert(qcyzsd == '—');
                           // alert(qcyzsd);
                            if (qcyzsd.indexOf('—')>=0) {
                                CopyTextToBookMark(pairs_[0], "前磁遇阻深度");
                                CopyTextToBookMark(pairs_[0], "前磁遇阻深度1"); 
                            }
                        }

                        if (pairs_[1] == "油顶") {

                            CopyTextToBookMark(pairs_[0], "油项");
                            CopyTextToBookMark(pairs_[0], "射孔井段1");
                            var dwdj = Number(pairs_[0]) - 40;
                            CopyTextToBookMark(dwdj, "定位短接");
                        }
                        else if (pairs_[1] == "油底") {
                            CopyTextToBookMark(pairs_[0], "射孔井段");
                            var youdi_depth = Number(pairs_[0]);

                            if(youdi_depth<1500){
                                p_safe = 9.0;
                            }
                            else if (youdi_depth < 2800) {
                                p_safe = 10.0;
                            }
                            else { //>=2800
                                p_safe = 14.0;
                            }

                        }
                        else if (pairs_[1] == "油管规格") {
                            var tmpVal = "73";
                            // alert(pairs_[0]);
                            if (pairs_[0].indexOf("73") > 0) {


                            }
                            else if (pairs_[0].indexOf("89") > 0) {
                                tmpVal = "89";
                            }

                            CopyTextToBookMark(tmpVal, "筛管");
                            CopyTextToBookMark(tmpVal, "油管接箍");
                            CopyTextToBookMark(tmpVal, "油管短接");
                        }
                        else if (pairs_[1] == "枪型") {

                            var tmpVal = pairs_[0].match(/\d+/g);
                            CopyTextToBookMark(tmpVal[0], "起爆装置接头");
                            CopyTextToBookMark(tmpVal[0], "枪尾");
                            CopyTextToBookMark(tmpVal[0], "枪尾死接头");
                        }
                        else if (pairs_[1] == "井号") {


                           // TANGER_OCX_OBJ.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader;
                           // Selection.TypeText(pairs_[0]);   //'字符内容
                           // TANGER_OCX_OBJ.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument;  //'退出页眉和页尾设置
                        }

                    }

                }
//                CopyTextToBookMark('1112', "油顶");
//                var bfl = ""; //百分率
//                $.ajax({
//                    type: "Post",
//                    url: "WordBrowse.aspx/GetBfl",
//                    //方法传参的写法一定要对，str为形参的名字,str2为第二个形参的名字     
//                    data: "{'wd':'" + wd + "'}",
//                    contentType: "application/json; charset=utf-8",
//                    dataType: "json",
//                    success: function (data) {
//                        //返回的数据用data.d获取内容     
//                        CopyTextToBookMark(data.d, "百分率");
//                        //alert(data.d);     
//                        bfl = data.d;
//                    },
//                    error: function (err) {
//                        alert(err);
//                    }
//                });
//                var τ = 3.09;
//                var Pmax = τ * 1.045 * (1 - bfl / 100);
//                Pmax = Pmax.toFixed(2);
//                CopyTextToBookMark(Pmax, "Pmax");


//                var Pmin = τ * 0.955 * (1 - bfl / 100);
//                Pmin = Pmin.toFixed(2);
//                CopyTextToBookMark(Pmin, "Pmin");
//                var n = (jyzyl + p_safe) / Pmin;
//                n = n.toFixed(2);
//                CopyTextToBookMark(n, "n");
//                var m = n;
//                m = Math.floor(m) + 1;
//                CopyTextToBookMark(m, "m");

//                //
//                var Ps = (m * Pmax) - jyzyl;
//                CopyTextToBookMark(Ps, "Ps");
//                var Px = (m * Pmin) - jyzyl;
//                CopyTextToBookMark(Px, "Px");

            }

        }

        function CopyTextToBookMark(inputValue, BookMarkName) {
            try {

                //do copy
                //DEBUG
                //alert(inputname+"="+inputValue+" Bookmarkname="+BookMarkName);
                var bkmkObj = TANGER_OCX_OBJ.ActiveDocument.BookMarks(BookMarkName);
                if (!bkmkObj) {
                    alert("Word 模板中不存在名称为：\"" + BookMarkName + "\"的书签！");
                }
                var saverange = bkmkObj.Range
                saverange.Text = inputValue;
                TANGER_OCX_OBJ.ActiveDocument.Bookmarks.Add(BookMarkName, saverange);


            }
            catch (err) { }
            finally {
            }
        }

        function getcookie(objname) {
            var arrstr = document.cookie.split("; ");
            for (var i = 0; i < arrstr.length; i++) {
                var temp = arrstr[i].split("=");
                if (temp[0] == objname) return unescape(temp[1]);
            }
        }
  
        function request(strParame) {


            if (strParame == "data") {

               // alert(unescape(getcookie("bookMarkAndData")));
                return unescape(getcookie("bookMarkAndData"));
            }
            var args = new Object();
            var query = location.search.substring(1);

            var pairs = query.split("&"); // Break at ampersand 
            for (var i = 0; i < pairs.length; i++) {
                var pos = pairs[i].indexOf('=');
                if (pos == -1) continue;
                var argname = pairs[i].substring(0, pos);
                var value = pairs[i].substring(pos + 1);
                value = decodeURIComponent(value);
                args[argname] = value;
            }
            return args[strParame];
        } 
    </script>
    <script type="text/javascript">

        wdDic = { 20: 0.00, 21: 0.18, 22: 0.36, 23: 0.54, 24: 0.72, 25: 0.90, 26: 0.96, 27: 1.02, 28: 1.08, 29: 1.14, 30: 1.20,
            31: 1.26, 32: 1.32, 33: 1.38, 34: 1.44, 35: 1.50, 36: 1.56, 37: 1.62, 38: 1.68, 39: 1.74, 40: 1.80,
            41: 1.98, 42: 2.16, 43: 2.34, 44: 2.52, 45: 2.70, 46: 2.78, 47: 2.86, 48: 2.94, 49: 3.02, 50: 3.10,
            51: 3.20, 52: 3.30, 53: 3.40, 54: 3.50, 55: 3.60, 56: 3.68, 57: 3.76, 58: 3.84, 59: 3.92, 60: 4.00,
            61: 4.10, 62: 4.20, 63: 4.30, 64: 4.40, 65: 4.50, 66: 4.60, 67: 4.70, 68: 4.80, 69: 4.90, 70: 5.00,
            71: 5.10, 72: 5.20, 73: 5.30, 74: 5.40, 75: 5.50, 76: 5.60, 77: 5.70, 78: 5.80, 79: 5.90, 80: 6.00,
            81: 6.10, 82: 6.20, 83: 6.30, 84: 6.40, 85: 6.50, 86: 6.60, 87: 6.70, 88: 6.80, 89: 6.90, 90: 7.00,
            91: 7.11, 92: 7.22, 93: 7.33, 94: 7.44, 95: 7.55, 96: 7.60, 97: 7.65, 98: 7.70, 99: 7.75, 100: 7.80,
            101: 7.88, 102: 7.96, 103: 8.04, 104: 8.12, 105: 8.20, 106: 8.30, 107: 8.40, 108: 8.50, 109: 8.60, 110: 8.70,
            111: 8.76, 112: 8.82, 113: 8.88, 114: 8.94, 115: 9.00, 116: 9.06, 117: 9.12, 118: 9.18, 119: 9.24, 120: 9.30,
            121: 9.38, 122: 9.46, 123: 9.54, 124: 9.62, 125: 9.70, 126: 9.78, 127: 9.86, 128: 9.94, 129: 10.02, 130: 10.10,
            131: 10.20, 132: 10.30, 133: 10.40, 134: 10.50, 135: 10.60, 136: 10.68, 137: 10.76, 138: 40.84, 139: 10.92, 140: 11.00,
            141: 11.10, 142: 11.20, 143: 11.30, 144: 11.40, 145: 11.50, 146: 11.60, 147: 11.70, 148: 11.80, 149: 11.90, 150: 12.00,
            151: 11.98, 152: 11.96, 153: 11.94, 154: 11.92, 155: 11.90, 156: 11.84, 157: 11.78, 158: 11.72, 159: 11.66, 160: 11.60,
            161: 11.48, 162: 11.36, 163: 11.24, 164: 11.12, 165: 11.00, 166: 10.94, 167: 10.88, 168: 10.82, 169: 10.76, 170: 10.70,
            171: 10.62, 172: 10.54, 173: 10.46, 174: 10.38, 175: 10.30, 176: 10.24, 177: 10.18, 178: 10.12, 179: 10.06, 180: 10.00,
            181: 9.92, 182: 9.84, 183: 9.76, 184: 9.68, 185: 9.60, 186: 9.52, 187: 9.44, 188: 9.36, 189: 9.28, 190: 9.20, 191: 9.16,
            192: 9.12, 193: 9.08, 194: 9.04, 195: 9.00, 196: 8.96, 197: 8.92, 198: 8.88, 199: 8.84, 200: 8.80, 201: 8.78, 202: 8.76,
            203: 8.74, 204: 8.72, 205: 8.70, 206: 8.68, 207: 8.66, 208: 8.64, 209: 8.62, 210: 8.60, 211: 8.58, 212: 8.56, 213: 8.54,
            214: 8.52, 215: 8.50, 216: 8.52, 217: 8.54, 218: 8.56, 219: 8.58, 220: 8.60
        }

        function testAddTable() {

            var tmp_id = escape(getParam("tempalteid"));





            var mydoc = TANGER_OCX_OBJ.ActiveDocument; //得到Document对象
            var app = mydoc.Application; //得到Application对象
            var sel = app.Selection; //得到Selection对象

            //安全压力，如果书签中设置值为14p 则安全压力默认为14p
            var bk_SafeP = TANGER_OCX_OBJ.ActiveDocument.BookMarks("P");
            //if (!bkmkObj) {
            //    alert("Word 模板中不存在名称为：\"" + BookMarkName + "\"的书签！");
            //}
            //alert(bkmkObj.Range.Text);
            if (bk_SafeP) {

                var safePValue = bk_SafeP.Range.Text;
                if (Number(safePValue) == 14) {
                    p_safe = 14;                
                }
            }



            //油顶分级油顶位置
            var bkmkObj = TANGER_OCX_OBJ.ActiveDocument.BookMarks("油顶分级油顶位置");
            if (!bkmkObj) {
                alert("Word 模板中不存在名称为：\"" + BookMarkName + "\"的书签！");
            }
            //alert(bkmkObj.Range.Text);
            var mark = bkmkObj.Range.Text;
            var marks = mark.split(';');
            var strData = request("data");
            var pairs = strData.split(";"); // Break at
            for (var j = 0; j < marks.length; j++) {
                var ss = marks[j].split(',');
                mydoc.Tables(2).Cell(ss[0], ss[1]).select();
                var type = ss[2];
                var maxRadio = 1.045;
                var minRadio = 0.955;
                if (type == '692') {
                    maxRadio = 1.05;
                    minRadio = 0.95;
                }

                if (j == 0) {
                    CopyTextToBookMark(sel.Text.substr(0, sel.Text.length - 2), "垂直深度");
                    var strData = request("data");
                    var pairs = strData.split(";"); // Break at
                    var wjymd = ""; //完井液密度
                    var skjd2 = ""; //射孔井段
                    var jyzyl = "0"; //静液柱压力
                    var wd = "0"; //温度

                    for (var i = 0; i < pairs.length - 1; i++) {
                        pairs_ = pairs[i].split(',');

                        if (pairs_[1] == "垂直深度") {
                            skjd2 = sel.Text;
                            skjd2 = parseFloat(skjd2);

                            if (skjd2 != "") {
                                wd = skjd2 * 0.035;
                                wd = Math.ceil(wd);

                            }
                            CopyTextToBookMark(wd, "温度");
                            //CopyTextToBookMark(pairs_[0], "垂直深度");


                            if (wjymd != "" && skjd2 != "") {
                                jyzyl = wjymd * skjd2 * 0.0098;
                            }
                            jyzyl = jyzyl.toFixed(2);
                            CopyTextToBookMark(jyzyl, "静液柱压力");

                        }
                        else if (pairs_[1] == "完井液密度") {
                            CopyTextToBookMark(pairs_[0], "完井液密度");
                            wjymd = pairs_[0];
                            CopyTextToBookMark(wjymd, "ρ");
                        }
                    }
                    var bfl = ""; //百分率
                    if (type == '692') {
                        bfl = wdDic[Number(wd)];

                        var τ = 3.09;
                        if (type == '692') {
                            τ = 3.67 * (1 - bfl / 100.0);
                            CopyTextToBookMark(τ, "S");
                        }
                        var Pmax = τ * maxRadio * (1 - bfl / 100);
                        Pmax = Pmax.toFixed(2);
                        CopyTextToBookMark(Pmax, "Pmax");
                        var Pmin = τ * minRadio * (1 - bfl / 100);
                        Pmin = Pmin.toFixed(2);
                        CopyTextToBookMark(Pmin, "Pmin");
                        CopyTextToBookMark(p_safe, "P");
                        var n = (Number(jyzyl) + p_safe) / Pmin;
                        n = n.toFixed(2);
                        CopyTextToBookMark(n, "n");
                        var m = n;
                        m = Math.floor(m) + 1;
                        CopyTextToBookMark(m, "m");

                        //
                        var Ps = (m * Pmax) - jyzyl;
                        Ps = Ps.toFixed(2);
                        CopyTextToBookMark(Ps, "Ps");
                        var Px = (m * Pmin) - jyzyl;
                        Px = Px.toFixed(2);
                        CopyTextToBookMark(Px, "Px");

                    }
                    else {
                        $.ajax({
                            type: "Post",
                            url: "WordBrowse.aspx/GetBfl",
                            //方法传参的写法一定要对，str为形参的名字,str2为第二个形参的名字     
                            data: "{'wd':'" + wd + "'}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                //返回的数据用data.d获取内容     
                                CopyTextToBookMark(data.d, "百分率");
                                //alert(data.d);     
                                bfl = data.d;


                                var τ = 3.09;
                                if (type == '692') {
                                    τ = 3.67 * (1 - bfl / 100.0);
                                    CopyTextToBookMark(τ, "S");
                                }
                                var Pmax = τ * maxRadio * (1 - bfl / 100);
                                Pmax = Pmax.toFixed(2);
                                CopyTextToBookMark(Pmax, "Pmax");
                                var Pmin = τ * minRadio * (1 - bfl / 100);
                                Pmin = Pmin.toFixed(2);
                                CopyTextToBookMark(Pmin, "Pmin");
                                CopyTextToBookMark(p_safe, "P");
                                var n = (Number(jyzyl) + p_safe) / Pmin;
                                n = n.toFixed(2);
                                CopyTextToBookMark(n, "n");
                                var m = n;
                                m = Math.floor(m) + 1;
                                CopyTextToBookMark(m, "m");

                                //
                                var Ps = (m * Pmax) - jyzyl;
                                Ps = Ps.toFixed(2);
                                CopyTextToBookMark(Ps, "Ps");
                                var Px = (m * Pmin) - jyzyl;
                                Px = Px.toFixed(2);
                                CopyTextToBookMark(Px, "Px");

                            },
                            error: function (err) {
                                alert(err);
                            }
                        });
                    }
                    

                }
                else if (j == 1) {
                    CopyTextToBookMark( sel.Text.substr(0, sel.Text.length - 2), "垂直深度1");

                    var strData = request("data");
                    var cs = request("cs");
                    //alert(cs);
                    CopyTextToBookMark(cs, "层数1");
                    var pairs = strData.split(";"); // Break at
                    var wjymd1 = ""; //完井液密度
                    var skjd21 = ""; //射孔井段
                    var jyzyl1 = "0"; //静液柱压力
                    var wd1 = "0"; //温度

                    for (var i = 0; i < pairs.length - 1; i++) {
                        pairs_ = pairs[i].split(',');

                        if (pairs_[1] == "垂直深度1") {
                            skjd21 = sel.Text;
                            skjd21 = parseFloat(skjd21);

                            if (skjd21 != "") {
                                wd1 = skjd21 * 0.035;
                                wd1 = wd1.toFixed(0);

                            }
                            CopyTextToBookMark(wd1, "温度1");
                            //CopyTextToBookMark(pairs_[0], "垂直深度");


                            if (wjymd1 != "" && skjd21 != "") {
                                jyzyl1 = wjymd1 * skjd21 * 0.0098;
                            }
                            jyzyl1 = jyzyl1.toFixed(2);
                            CopyTextToBookMark(jyzyl1, "静液柱压力1");

                        }
                        else if (pairs_[1] == "完井液密度") {
                            CopyTextToBookMark(pairs_[0], "完井液密度1");
                            wjymd1 = pairs_[0];
                            CopyTextToBookMark(wjymd1, "ρ1");
                        }
                    }

                    var bfl = ""; //百分率
                    if (type == '692') {
                        bfl = wdDic[Number(wd)];
                        var τ = 3.09;
                        if (type == '692') {
                            τ = 3.67 * (1 - bfl / 100.0);
                            CopyTextToBookMark(τ, "S1");
                        }
                        var Pmax = τ * maxRadio * (1 - bfl / 100);
                        Pmax = Pmax.toFixed(2);
                        CopyTextToBookMark(Pmax, "Pmax1");


                        var Pmin = τ * minRadio * (1 - bfl / 100);
                        Pmin = Pmin.toFixed(2);
                        CopyTextToBookMark(Pmin, "Pmin1");
                        CopyTextToBookMark(p_safe, "P1");
                        var n = ( Number( jyzyl1) + p_safe) / Pmin;
                        n = n.toFixed(2);
                        CopyTextToBookMark(n, "n1");
                        var m = n;
                        m = Math.floor(m) + 1;
                        CopyTextToBookMark(m, "m1");

                        //
                        var Ps = (m * Pmax) - jyzyl1;
                        Ps = Ps.toFixed(2);
                        CopyTextToBookMark(Ps, "Ps1");
                        var Px = (m * Pmin) - jyzyl1;
                        Px = Px.toFixed(2);
                        CopyTextToBookMark(Px, "Px1");

                    }
                    else {
                        $.ajax({
                            type: "Post",
                            url: "WordBrowse.aspx/GetBfl",
                            //方法传参的写法一定要对，str为形参的名字,str2为第二个形参的名字     
                            data: "{'wd':'" + wd1 + "'}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                //返回的数据用data.d获取内容     
                                CopyTextToBookMark(data.d, "百分率1");
                                //alert(data.d);     
                                bfl = data.d;


                                var τ = 3.09;
                                if (type == '692') {
                                    τ = 3.67 * (1 - bfl / 100.0);
                                    CopyTextToBookMark(τ, "S1");
                                }
                                var Pmax = τ * maxRadio * (1 - bfl / 100);
                                Pmax = Pmax.toFixed(2);
                                CopyTextToBookMark(Pmax, "Pmax1");


                                var Pmin = τ * minRadio * (1 - bfl / 100);
                                Pmin = Pmin.toFixed(2);
                                CopyTextToBookMark(Pmin, "Pmin1");
                                CopyTextToBookMark(p_safe, "P1");
                                var n = (Number(jyzyl1) + p_safe) / Pmin;
                                n = n.toFixed(2);
                                CopyTextToBookMark(n, "n1");
                                var m = n;
                                m = Math.floor(m) + 1;
                                CopyTextToBookMark(m, "m1");

                                //
                                var Ps = (m * Pmax) - jyzyl1;
                                Ps = Ps.toFixed(2);
                                CopyTextToBookMark(Ps, "Ps1");
                                var Px = (m * Pmin) - jyzyl1;
                                Px = Px.toFixed(2);
                                CopyTextToBookMark(Px, "Px1");



                            },
                            error: function (err) {
                                alert(err);
                            }
                        });
                    }
                    
                }
                else if (j == 2) {
                    CopyTextToBookMark(sel.Text.substr(0, sel.Text.length - 2), "垂直深度2");

                    var strData = request("data");
                    var cs = request("cs");
                    //alert(cs);
                    CopyTextToBookMark(cs, "层数2");
                    var pairs = strData.split(";"); // Break at
                    var wjymd1 = ""; //完井液密度
                    var skjd21 = ""; //射孔井段
                    var jyzyl2 = "0"; //静液柱压力
                    var wd1 = "0"; //温度

                    for (var i = 0; i < pairs.length - 1; i++) {
                        pairs_ = pairs[i].split(',');

                        if (pairs_[1] == "垂直深度2") {
                            skjd21 = sel.Text;
                            skjd21 = parseFloat(skjd21);

                            if (skjd21 != "") {
                                wd1 = skjd21 * 0.035;
                                wd1 = wd1.toFixed(0);

                            }
                            CopyTextToBookMark(wd1, "温度2");
                            //CopyTextToBookMark(pairs_[0], "垂直深度");


                            if (wjymd1 != "" && skjd21 != "") {
                                jyzyl2 = wjymd1 * skjd21 * 0.0098;
                            }
                            jyzyl2 = jyzyl2.toFixed(2);
                            CopyTextToBookMark(jyzyl2, "静液柱压力2");

                        }
                        else if (pairs_[1] == "完井液密度") {
                            CopyTextToBookMark(pairs_[0], "完井液密度2");
                            wjymd1 = pairs_[0];
                            CopyTextToBookMark(wjymd1, "ρ2");
                        }
                    }

                    var bfl = ""; //百分率
                    if (type == '692') {
                        bfl = wdDic[Number(wd)];
                        var τ = 3.09;
                        if (type == '692') {
                            τ = 3.67 * (1 - bfl / 100.0);
                            CopyTextToBookMark(τ, "S2");
                        }
                        var Pmax = τ * maxRadio * (1 - bfl / 100);
                        Pmax = Pmax.toFixed(2);
                        CopyTextToBookMark(Pmax, "Pmax2");


                        var Pmin = τ * minRadio * (1 - bfl / 100);
                        Pmin = Pmin.toFixed(2);
                        CopyTextToBookMark(Pmin, "Pmin2");
                        CopyTextToBookMark(p_safe, "P2");
                        var n = (Number(jyzyl2) + p_safe) / Pmin;
                        n = n.toFixed(2);
                        CopyTextToBookMark(n, "n2");
                        var m = n;
                        m = Math.floor(m) + 1;
                        CopyTextToBookMark(m, "m2");

                        //
                        var Ps = (m * Pmax) - jyzyl2;
                        Ps = Ps.toFixed(2);
                        CopyTextToBookMark(Ps, "Ps2");
                        var Px = (m * Pmin) - jyzyl2;
                        Px = Px.toFixed(2);
                        CopyTextToBookMark(Px, "Px2");
                    }
                    else {
                        $.ajax({
                            type: "Post",
                            url: "WordBrowse.aspx/GetBfl",
                            //方法传参的写法一定要对，str为形参的名字,str2为第二个形参的名字     
                            data: "{'wd':'" + wd1 + "'}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                //返回的数据用data.d获取内容     
                                CopyTextToBookMark(data.d, "百分率2");
                                //alert(data.d);     
                                bfl = data.d;


                                var τ = 3.09;
                                if (type == '692') {
                                    τ = 3.67 * (1 - bfl / 100.0);
                                    CopyTextToBookMark(τ, "S2");
                                }
                                var Pmax = τ * maxRadio * (1 - bfl / 100);
                                Pmax = Pmax.toFixed(2);
                                CopyTextToBookMark(Pmax, "Pmax2");


                                var Pmin = τ * minRadio * (1 - bfl / 100);
                                Pmin = Pmin.toFixed(2);
                                CopyTextToBookMark(Pmin, "Pmin2");
                                CopyTextToBookMark(p_safe, "P2");
                                var n = (Number(jyzyl2) + p_safe) / Pmin;
                                n = n.toFixed(2);
                                CopyTextToBookMark(n, "n2");
                                var m = n;
                                m = Math.floor(m) + 1;
                                CopyTextToBookMark(m, "m2");


                                //CopyTextToBookMark(m, "P2");

                                //
                                var Ps = (m * Pmax) - jyzyl2;
                                Ps = Ps.toFixed(2);
                                CopyTextToBookMark(Ps, "Ps2");
                                var Px = (m * Pmin) - jyzyl2;
                                Px = Px.toFixed(2);
                                CopyTextToBookMark(Px, "Px2");
                            },
                            error: function (err) {
                                alert(err);
                            }
                        });
                    }
                   
                }
                else if (j == 3) {
                    CopyTextToBookMark(sel.Text.substr(0, sel.Text.length - 2), "垂直深度3");

                    var strData = request("data");
                    var cs = request("cs");
                    //alert(cs);
                    CopyTextToBookMark(cs, "层数3");
                    var pairs = strData.split(";"); // Break at
                    var wjymd1 = ""; //完井液密度
                    var skjd21 = ""; //射孔井段
                    var jyzyl3 = "0"; //静液柱压力
                    var wd1 = "0"; //温度

                    for (var i = 0; i < pairs.length - 1; i++) {
                        pairs_ = pairs[i].split(',');

                        if (pairs_[1] == "垂直深度3") {
                            skjd21 = sel.Text;
                            skjd21 = parseFloat(skjd21);

                            if (skjd21 != "") {
                                wd1 = skjd21 * 0.035;
                                wd1 = wd1.toFixed(0);

                            }
                            CopyTextToBookMark(wd1, "温度3");
                            //CopyTextToBookMark(pairs_[0], "垂直深度");


                            if (wjymd1 != "" && skjd21 != "") {
                                jyzyl3 = wjymd1 * skjd21 * 0.0098;
                            }
                            jyzyl3 = jyzyl3.toFixed(2);
                            CopyTextToBookMark(jyzyl3, "静液柱压力3");

                        }
                        else if (pairs_[1] == "完井液密度") {
                            CopyTextToBookMark(pairs_[0], "完井液密度3");
                            wjymd1 = pairs_[0];
                            CopyTextToBookMark(wjymd1, "ρ3");
                        }
                    }

                    var bfl = ""; //百分率
                    if (type == '692') {
                        bfl = wdDic[Number(wd)];


                        var τ = 3.09;
                        if (type == '692') {
                            τ = 3.67 * (1 - bfl / 100.0);
                            CopyTextToBookMark(τ, "S3");
                        }
                        var Pmax = τ * maxRadio * (1 - bfl / 100);
                        Pmax = Pmax.toFixed(2);
                        CopyTextToBookMark(Pmax, "Pmax3");


                        var Pmin = τ * minRadio * (1 - bfl / 100);
                        Pmin = Pmin.toFixed(2);
                        CopyTextToBookMark(Pmin, "Pmin3");
                        CopyTextToBookMark(p_safe, "P3");
                        var n = (Number(jyzyl3) + p_safe) / Pmin;
                        n = n.toFixed(2);
                        CopyTextToBookMark(n, "n3");
                        var m = n;
                        m = Math.floor(m) + 1;
                        CopyTextToBookMark(m, "m3");

                        //
                        var Ps = (m * Pmax) - jyzyl3;
                        Ps = Ps.toFixed(2);
                        CopyTextToBookMark(Ps, "Ps3");
                        var Px = (m * Pmin) - jyzyl3;
                        Px = Px.toFixed(2);
                        CopyTextToBookMark(Px, "Px3");
                    }
                    else {
                        $.ajax({
                            type: "Post",
                            url: "WordBrowse.aspx/GetBfl",
                            //方法传参的写法一定要对，str为形参的名字,str2为第二个形参的名字     
                            data: "{'wd':'" + wd1 + "'}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                //返回的数据用data.d获取内容     
                                CopyTextToBookMark(data.d, "百分率3");
                                //alert(data.d);     
                                bfl = data.d;


                                var τ = 3.09;
                                if (type == '692') {
                                    τ = 3.67 * (1 - bfl / 100.0);
                                    CopyTextToBookMark(τ, "S3");
                                }
                                var Pmax = τ * maxRadio * (1 - bfl / 100);
                                Pmax = Pmax.toFixed(2);
                                CopyTextToBookMark(Pmax, "Pmax3");


                                var Pmin = τ * minRadio * (1 - bfl / 100);
                                Pmin = Pmin.toFixed(2);
                                CopyTextToBookMark(Pmin, "Pmin3");
                                CopyTextToBookMark(p_safe, "P3");
                                var n = (Number(jyzyl3) + p_safe) / Pmin;
                                n = n.toFixed(2);
                                CopyTextToBookMark(n, "n3");
                                var m = n;
                                m = Math.floor(m) + 1;
                                CopyTextToBookMark(m, "m3");

                                //
                                var Ps = (m * Pmax) - jyzyl3;
                                Ps = Ps.toFixed(2);
                                CopyTextToBookMark(Ps, "Ps3");
                                var Px = (m * Pmin) - jyzyl3;
                                Px = Px.toFixed(2);
                                CopyTextToBookMark(Px, "Px3");

                            },
                            error: function (err) {
                                alert(err);
                            }
                        });
                    }
                    
                }
                else if (j == 4) {
                    CopyTextToBookMark(sel.Text.substr(0, sel.Text.length - 2), "垂直深度4");

                    var strData = request("data");
                    var cs = request("cs");
                    //alert(cs);
                    CopyTextToBookMark(cs, "层数4");
                    var pairs = strData.split(";"); // Break at
                    var wjymd1 = ""; //完井液密度
                    var skjd21 = ""; //射孔井段
                    var jyzyl4 = "0"; //静液柱压力
                    var wd1 = "0"; //温度

                    for (var i = 0; i < pairs.length - 1; i++) {
                        pairs_ = pairs[i].split(',');

                        if (pairs_[1] == "垂直深度4") {
                            skjd21 = sel.Text;
                            skjd21 = parseFloat(skjd21);

                            if (skjd21 != "") {
                                wd1 = skjd21 * 0.035;
                                wd1 = wd1.toFixed(0);

                            }
                            CopyTextToBookMark(wd1, "温度4");
                            //CopyTextToBookMark(pairs_[0], "垂直深度");


                            if (wjymd1 != "" && skjd21 != "") {
                                jyzyl4 = wjymd1 * skjd21 * 0.0098;
                            }
                            jyzyl4 = jyzyl4.toFixed(2);
                            CopyTextToBookMark(jyzyl4, "静液柱压力4");

                        }
                        else if (pairs_[1] == "完井液密度") {
                            CopyTextToBookMark(pairs_[0], "完井液密度4");
                            wjymd1 = pairs_[0];
                            CopyTextToBookMark(wjymd1, "ρ4");
                        }
                    }

                    var bfl = ""; //百分率
                    if (type == '692') {
                        bfl = wdDic[Number(wd)];


                        var τ = 3.09;
                        if (type == '692') {
                            τ = 3.67 * (1 - bfl / 100.0);
                            CopyTextToBookMark(τ, "S4");
                        }
                        var Pmax = τ * maxRadio * (1 - bfl / 100);
                        Pmax = Pmax.toFixed(2);
                        CopyTextToBookMark(Pmax, "Pmax4");
                        var Pmin = τ * minRadio * (1 - bfl / 100);
                        Pmin = Pmin.toFixed(2);
                        CopyTextToBookMark(Pmin, "Pmin4");
                        CopyTextToBookMark(p_safe, "P4");
                        var n = (Number(jyzyl4) + p_safe) / Pmin;
                        n = n.toFixed(2);
                        CopyTextToBookMark(n, "n4");
                        var m = n;
                        m = Math.floor(m) + 1;
                        CopyTextToBookMark(m, "m4");
                        //
                        var Ps = (m * Pmax) - jyzyl4;
                        Ps = Ps.toFixed(2);
                        CopyTextToBookMark(Ps, "Ps4");
                        var Px = (m * Pmin) - jyzyl4;
                        Px = Px.toFixed(2);
                        CopyTextToBookMark(Px, "Px4");
                    }
                    else {
                        $.ajax({
                            type: "Post",
                            url: "WordBrowse.aspx/GetBfl",
                            //方法传参的写法一定要对，str为形参的名字,str2为第二个形参的名字     
                            data: "{'wd':'" + wd1 + "'}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                //返回的数据用data.d获取内容     
                                CopyTextToBookMark(data.d, "百分率4");
                                //alert(data.d);     
                                bfl = data.d;


                                var τ = 3.09;
                                if (type == '692') {
                                    τ = 3.67 * (1 - bfl / 100.0);
                                    CopyTextToBookMark(τ, "S4");
                                }
                                var Pmax = τ * maxRadio * (1 - bfl / 100);
                                Pmax = Pmax.toFixed(2);
                                CopyTextToBookMark(Pmax, "Pmax4");
                                var Pmin = τ * minRadio * (1 - bfl / 100);
                                Pmin = Pmin.toFixed(2);
                                CopyTextToBookMark(Pmin, "Pmin4");
                                CopyTextToBookMark(p_safe, "P5");
                                var n = (Number(jyzyl4) + p_safe) / Pmin;
                                n = n.toFixed(2);
                                CopyTextToBookMark(n, "n4");
                                var m = n;
                                m = Math.floor(m) + 1;
                                CopyTextToBookMark(m, "m4");
                                //
                                var Ps = (m * Pmax) - jyzyl4;
                                Ps = Ps.toFixed(2);
                                CopyTextToBookMark(Ps, "Ps4");
                                var Px = (m * Pmin) - jyzyl4;
                                Px = Px.toFixed(2);
                                CopyTextToBookMark(Px, "Px4");

                            },
                            error: function (err) {
                                alert(err);
                            }
                        });
                    }
                    
                }
            }  //end of for loop
            alert("计算结束");
        } 

    </script>
</head>
<body style="width: 100%; height: 100%; margin: 0px">
    <form id="form1" runat="server">

    <div class="easyui-panel tool_div" style="padding:5px;"  align="right">
    

        <a href="javascript:testAddTable()"   class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'"> 销钉计算 </a>
        <a href="#" id="save" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save'"> 保存并提交 </a>
   
    </div>

       <asp:HiddenField ID="HiddenField1" runat="server" />
    <%--<div id="buttons" style="text-align: right;">
        <input type="button" onclick="testAddTable()" value="销钉计算" />
        <asp:HiddenField ID="hidFJ" runat="server" />
        <input type="button" id="save" value="保存并提交" />
       <%-- <input type="button" id="cancel" value="取消" />--%>
    <%-- </div>--%>
    <%-- <a id="aSubmitSave" href="javascript:void(0)" class="easyui-linkbutton">保存</a>--%>
    <%--  <asp:Button ID="btnSubmit" runat="server" Text="提交" onclick="btnSubmit_Click" />
     <input type="button" value="加密" />--%>
    <div style="height: 100%">
        <object id="TANGER_OCX" classid="clsid:C9BC4DFF-4248-4a3c-8A49-63A7D317F404" codebase="OfficeControl.cab#version=5,0,2,1"
            width="98%" height="700px">
            <param name="Titlebar" value="false" />
            <param name="Menubar" value="true" />
            <param name="Toolbars" value="true" />
            <param name="Statusbar" value="false" />
            <param name="BorderStyle" value="0" />
            <param name="FileNew" value="false" />
            <param name="FileOpen" value="false" />
            <param name="FileClose" value="false" />
            <param name="FileSave" value="true" />
            <param name="FileSaveAs" value="true" />
            <param name="FilePrint" value="true" />
            <param name="ProductCaption" value="东北石油大学" />
            <param name="ProductKey" value="DAFA0D7CDF60CD7EEBCD8C79AB0E04D3875EB82C" />
            ..... <span style="color: red">该网页需要控件浏览.浏览器无法装载所需要的文档控件.请检查浏览器选项中的安全设置.</span>
        </object>
    </div>
    <script type="text/javascript">

        var TANGER_OCX_OBJ = document.getElementById("TANGER_OCX");
        TANGER_OCX_OBJ.Titlebar=false;
        TANGER_OCX_OBJ.Menubar = false;



        file = getParam("name");
        if (file) {
            TANGER_OCX_OBJ.OpenFromURL("../" + escape(file));
            //TANGER_OCX_OBJ.OpenFromURL("../tempDoc/" + escape(file));
            TANGER_OCX_OBJ.ActiveDocument.ActiveWindow.DocumentMap = true;
            tt();
        } else {//不包含name参数，则包含path参数，文件从ftp服务器得到
            path = getParam("path");
            if (path) {

                $("#buttons").hide();
                TANGER_OCX_OBJ.OpenFromURL("../" + escape(path));
                //TANGER_OCX_OBJ.OpenFromURL("../tempDoc/" + escape(file));
                TANGER_OCX_OBJ.ActiveDocument.ActiveWindow.DocumentMap = true;
            }
        }
       
    </script>
    </form>
</body>
</html>
